<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<div id="container">
  <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>

  <div id="outer" style="height: 100px; overflow: scroll">
    <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
    <div id="inner" style="height: 100px; overflow: scroll">
      <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
      <button id="target">Target</button>
    </div>
  </div>
</div>

<div id="console"></div>

<script>
test(function(t) {
    var axWebArea = accessibilityController.rootElement;
    assert_equals(axWebArea.role, "AXRole: AXRootWebArea");

    assert_true(axWebArea.isScrollableContainer);
    assert_equals(axWebArea.scrollOffsetY, 0);
    assert_not_equals(axWebArea.maxScrollOffsetY, 0);
    axWebArea.setScrollOffset(0, axWebArea.maxScrollOffsetY);
    assert_equals(axWebArea.scrollOffsetY, axWebArea.maxScrollOffsetY);

    var axOuter = accessibilityController.accessibleElementById("outer");
    assert_true(axOuter.isScrollableContainer);
    assert_equals(axOuter.scrollOffsetY, 0);
    assert_not_equals(axOuter.maxScrollOffsetY, 0);
    axOuter.setScrollOffset(0, axOuter.maxScrollOffsetY);
    assert_equals(axOuter.scrollOffsetY, axOuter.maxScrollOffsetY);

    var axInner = accessibilityController.accessibleElementById("inner");
    assert_true(axInner.isScrollableContainer);
    assert_equals(axInner.scrollOffsetY, 0);
    assert_not_equals(axInner.maxScrollOffsetY, 0);
    axInner.setScrollOffset(0, axInner.maxScrollOffsetY);
    assert_equals(axInner.scrollOffsetY, axInner.maxScrollOffsetY);

    var axTarget = accessibilityController.accessibleElementById("target");
    assert_false(axTarget.isScrollableContainer);
}, "Test scroll container APIs.");

if (window.testRunner)
    document.getElementById("container").style.display = "none";
</script>
